<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>我的参团</title>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <!--weui.min.css-->
    <link rel="stylesheet" href="/static/index/css/page/base.css"/>
    <link rel="stylesheet" href="/static/index/css/page/font.css"/>
    <link rel="stylesheet" href="/static/index/jquery_weui/css/swiper.min.css"/>
    <link rel="stylesheet" type="text/css" href="/static/index/jquery_weui/lib/weui.min.css">
    <!--jquery-weui.min.css-->
    <link rel="stylesheet" type="text/css" href="/static/index/jquery_weui/css/jquery-weui.min.css">
    <link rel="stylesheet" href="/static/index/css/page/personal.css" />
</head>
<body>
	<style>
    /*上传input*/
    .myUpload
    {
        position: absolute;
        opacity: 0;
        z-index: 100;
        width: 100%;
        height: 100%;
        display: block;
    }
    /*关闭按钮*/
    .close
    {
        position: absolute;
        right: 0;
        top: 0;
        width: 20px;
        height: 20px;
        z-index: 200;
        cursor: pointer;
    }
    /*隐藏*/
    .hideimg
    {
        display: none;
    }
    /*上传的图片*/
    .addimg
    {
        width: 100%;
        height: 100%;
    }
    /*显示上传的图片*/
    .showimg
    {
        width: 100%;
        height: 100%;
    }
    #dtxz{
        width: 6rem;
        height: 4rem;
        float: left;
        margin: 4% auto;
    }
    .submit{
        float: left;
    }
    /*图片处理css*/
	.list2 .swiper-slide>a{
		overflow: hidden;
		position: relative;
	}
	.list2 .swiper-slide>a img{
		
		position: absolute;
		left: 50%;
		top: 50%;
	}
</style>
<div class="pageControl offered bg-f5">
    <!--主体-->
    <div class="main">
        <div class="bg-di"></div>
        <div class="msui_nav msui_navTop">
            <a class="msui_navTop-back" href="javascript:history.back();"><i class="micon-back"></i></a>
            <h1 class="msui_navTop-title">我的参团</h1>
        </div>
        <div class="main offered-list personal-list">
        	{foreach $info as $k => $v}
            <div class="list t0">
                <div class="list2">
                    <!--‘正在’加class为state1，‘将要’class为state2，完成class为state3-->
                    {if $v['is_end'] eq 1}
                    	<span class="state state3">完成</span>
                    {else}
	                    {if $v['is_start'] eq 1}
	                    	<span class="state state1">正在</span>
	                    {else}
	                   		<span class="state state2">将要</span>
	                    {/if}
                    {/if}

                    <p class="list2-a">{$v.content}</p>
                    <div class="swiper-container">
                    	<?php $ssh = explode("|",$v['photo']);?>
	                        <div class="swiper-wrapper">
	                    	{foreach name="ssh" item="tour_photo"}
	                            <div class="swiper-slide">
	                                <a href="/index/index/detail?id={$v.id}&uid={$v.user_id}"><img src="{$tour_photo}" alt=""/></a>
	                            </div>
	                        {/foreach}
	                        </div>
                        <div class="pic-count"><?php echo count($ssh)?>张</div>
                    </div>
                    <div class="weui-cell1">
                        <div class="weui-cell__bd"></div>
                        <div class="weui-cell__ft">
                            <img src="/static/index/img/x2.png" alt=""/>
                            <span>{$v.count}</span>
                        </div>
                        <div class="weui-cell__ft">
                            <img src="/static/index/img/x3.png" alt=""/>
                            <span>{$v.comment_count}</span>
                        </div>
                        <div class="weui-cell__ft">
                        	<a href="/index/personal/offered_del?id={$v.id}&uid={$id}">
                           		<img src="/static/index/img/g3.png" alt=""/>
                           	</a>
                        </div>
                    </div>
                </div>
                <!--开始活动按钮-->
                {if $v.button_status eq 0}
	                <div class="publish-radio start">
	                    <div class="weui-cell__bd">
	                        <span class="fs065">是否开始活动</span>
	                    </div>
	                    <div class="weui-cell__ft">
	                        <a href="/index/index/start_active_agree?user_id={$id}&active_id={$v.id}" id="start_button" class="radio-btn bg-ff7 cl-f fs07">确认</a>
	                    </div>
	                    
	                </div>
	                {if $v.is_report eq 1}
	                    <div class="publish-radio end">
	                          <span class="fs065">已举报。正在调查ing</span>
	                    </div>
	                {else}
	                    <div class="publish-radio end">
	                        <div class="weui-cell__bd">
	                           <span class="fs065">是否举报发起人</span>
	                        </div>
	                        <div class="weui-cell__ft">
	                           <a class="radio-btn bg-ff7 cl-f fs07 report"><input type="hidden" class="active_id" value="{$v.id}">确认</a>
	                        </div>
	                    </div>
	                {/if}
                {elseif $v.button_status eq 1}
	                <!--结束活动按钮-->
	                <div class="publish-radio end">
	                    <div class="weui-cell__bd">
	                        <span class="fs065">是否结束活动</span>
	                    </div>
	                    <div class="weui-cell__ft">
	                        <a href="javascript:;" class="radio-btn bg-ff7 cl-f fs07 active_end">确认</a>
                            <input type="hidden" value="{$v.id}" class="active_id" />
	                    </div>
	                </div>
		            {if $v.is_report eq 1}
	                    <div class="publish-radio end">
	                          <span class="fs065">已举报。正在调查ing</span>
	                    </div>
	                {else}
	                    <div class="publish-radio end">
	                        <div class="weui-cell__bd">
	                           <span class="fs065">是否举报发起人</span>
	                        </div>
	                        <div class="weui-cell__ft">
	                           <a class="radio-btn bg-ff7 cl-f fs07 report"><input type="hidden" class="active_id" value="{$v.id}">确认</a>
	                        </div>
	                    </div>
	                {/if}
	            
                {/if}
                 
            </div>
            {/foreach}
        </div>
    </div>
</div>
<!-- jquery-2.1.4 -->
<script type="text/javascript" src="/static/index/jquery_weui/lib/jquery-2.1.4.js"></script>
<!--jquery.cookie.js-->
<script type="text/javascript" src="/static/index/jquery_weui/js/jquery.cookie.js"></script>
<!-- jquery-weui.min.js -->
<script type="text/javascript" src="/static/index/jquery_weui/js/jquery-weui.min.js"></script>
<script src="/static/index/jquery_weui/js/swiper.min.js"></script>
<script>
	
	
	             //举报处理
        $('.report').click(function (){
            var active_id = $(this).find('.active_id').val();
            var res=prompt("请输入举报原因","");
            $.ajax({
                type:'post',
                url:'/index/personal/report',
                data:{active_id:active_id,report_con:res},
                success:function(data){
                    alert(data);return;
                    if(data =="1"){
                        alert('举报成功，待审核。。。');
                    }else if(data =="-1"){
                        alert('举报失败');
                    }else if(data =="2"){
                        alert('所有参与者已举报，押金已返还');
                    }
                }
            });
        });
		$(function(){
//		图片处理
		$('.personal-list .swiper-slide>a img').each(function(){
			
			var imgWidth=-parseFloat($(this).css('width'))/2;
			var imgHeight=-parseFloat($(this).css('height'))/2;
			console.log(imgWidth)
			console.log(imgHeight)
			
			var imgWidth1=parseFloat($(this).css('width'));
			var imgHeight1=parseFloat($(this).css('height'));
			if(imgWidth1>=imgHeight1){
				$(this).css({
					height:'100%',
					width:'auto'
				})
			$(this).css('top','0')
			$(this).css('margin-left',imgWidth)
			}else if(imgWidth1<imgHeight1){
				$(this).css({
					height:'auto',
					width:'100%'
				})
				$(this).css('margin-top',imgHeight)
				$(this).css('margin-left',imgWidth)
			}
		})
		
		
		var swiperWidth=$('.list .swiper-slide').width();
		console.log(swiperWidth)
		$('.list .swiper-slide').css('height',swiperWidth)
		$('.list .swiper-slide>a img').css('min-height',swiperWidth)
		
		$('.noteMemo').each(function(){
		var ttCount=$(this).find('.index-btn1 a.note-list').length;
		var listCount=$(this).find('.index-btn1 a').length;
		if(listCount>4){
			for(var i=1;i<=ttCount;i++){
				if(i>3){
					$(this).find(`.index-btn1 a.note-list:nth-of-type(${i})`).css('display','none')
				}
			}
			$(this).find('.note-more').css('display','inline-block')
		}else if(listCount<=4){
			$(this).find('.note-more').css('display','none')
		}
    console.log(listCount)
	})
	})
	
    var swiper = new Swiper('.swiper-container', {
        slidesPerView: 3,
        spaceBetween: 5
    });
    $(".active_end").click(function (e) {
    	var active_id = $('.active_id').val();
        var uid = {$id};//当前登录用户id，用于页面跳转
        $.post(
			"/index/personal/active_end",
			{active_id: active_id},
		    function(data){
		    	if(data.code == 200){
		    		alert(data.msg);
		    		window.location.href="/index/personal/offered";
		    	}
	   		},'json'
		);

    })
    $(".weui-cells_radio").on("click",'.weui-check__label',function(){
        $(this).children('input').attr('checked','checked')
        $(this).siblings().children('input').removeAttr('checked')
    })
    var listLength=$(".offered-list").children().length;
    /*for(var i=0;i<listLength;i++){
        var slider_length=$(`.offered-list .t${i} .swiper-wrapper`).children().length;
        $(`.offered-list .t${i} .pic-count`).html(slider_length+"张")
    }*/
    
    //上传图片
    $(function(){
        //点击上传时实时显示图片
        $(".sctp").on("change",".myUpload",function(){
            var src=getObjectURL(this.files[0]);//获取上传文件的路径
            $(this).siblings(".close").removeClass('hideimg');
            $(this).siblings(".addimg").addClass('hideimg');
            $(this).siblings(".showimg").removeClass('hideimg');
            $(this).siblings(".showimg").attr('src',src);//把路径赋值给img标签
            $(this).siblings(".addimg").remove();
        });

        //点击关闭按钮时恢复初始状态
        $(".close").on("click",function(){
            var file=$(this).parent().find(".myUpload");
            file.after(file.clone().val(""));
            file.remove();
            $(this).addClass('hideimg');
            $(this).siblings(".addimg").removeClass('hideimg');
            $(this).siblings(".showimg").addClass('hideimg');
            $(this).siblings(".showimg").removeAttr('src');//把img标签路径移除
        });
    });

    //获取上传文件的url
    function getObjectURL(file)
    {
        var url = null;
        if (window.createObjectURL != undefined)
        {
            url = window.createObjectURL(file);
        }
        else if (window.URL != undefined)
        {
            url = window.URL.createObjectURL(file);
        }
        else if (window.webkitURL != undefined)
        {
            url = window.webkitURL.createObjectURL(file);
        }
        return url;
    }
</script>
</body>
</html>

